﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ENMAX_ArcGIS
{
    /// <summary>
    /// This class represents a picture map which is inserted in a looping panel.
    /// It hold the information needed to create the map from this picture...
    /// For example, it holds the name of the map, the position in Latitude and Longitude, zoom level,...etc.
    /// The picture itself is changed according to the last modifications done to it.
    /// TODO:   - Decide whether preserving the changes is done when the actual map is closed or when the changes are done.
    ///         - Decide whether the set of pictures will be shared by all looping panels or each one will have its own set of pictures.
    /// 
    /// </summary>
    public class PanelPictureMap
    {
        string mapId;
        double latitude;
        double longitude;
        double zoomLevel;
        string imagePath;

        # region constructor

        public PanelPictureMap(string newMapId)
        {
            mapId = newMapId;
        }

        # endregion

        # region Properties get/set

        public string MapId
        {
            get
            {
                return mapId;
            }

            set
            {
                mapId = value;
            }
        }

        public double Latitude
        {
            get
            {
                return latitude;
            }

            set
            {
                latitude = value;

                // TODO: do we need to modify something here?
            }
        }

        public double Longitude
        {
            get
            {
                return longitude;
            }

            set
            {
                longitude = value;

                // TODO: do we need to modify something here?
            }
        }

        public double ZoomLevel
        {
            get
            {
                return zoomLevel;
            }

            set
            {
                zoomLevel = value;

                // TODO: do we need to modify something here?
            }
        }

        public string ImagePath
        {
            get
            {
                return imagePath;
            }

            set
            {
                imagePath = value;

                // TODO: do we need to modify something here?
            }
        }

        # endregion

        #region static functions
        /// <summary>
        /// Create the Panel Picture Map corresponding to the image name and path
        /// </summary>
        /// <param name="imageName"></param>
        /// <param name="imagePath"></param>
        /// <returns></returns>
        public static PanelPictureMap createPanelPictureMap(string imageName, string imagePath)
        {
            PanelPictureMap thePictureMap = new PanelPictureMap(imageName);

            // Table of Lattitudes and Longitudes
            // Used this: javascript:void(prompt('',gApplication.getMap().getCenter()));

            // Calgary    -> (51.055149, -114.062438)
            // Edmonton   -> (53.540941, -113.493698)
            // BanffTrail -> (51.062871, -114.086226)
            // Brentwood  -> (51.087189056051685, -114.13224220275879)
            // Dalhousie  -> (51.1033333116351, -114.16082382202148)
            // Saskatoon  -> (51.06432411023551, -114.03851509094238)
            // University -> (51.06205857130617, -114.09524917602539)
            // Winnipeg   -> (51.03351407558057, -114.03619766235352)

            double lon = 0;
            double lat = 0;

            if (imageName.Equals("Calgary"))
            {
                lat = 51.055149;
                lon = -114.062438;
            }
            else if (imageName.Equals("Edmonton"))
            {
                lat = 53.540941;
                lon = -113.493698;
            }
            else if (imageName.Equals("Banff Trail"))
            {
                lat = 51.062871;
                lon = -114.086226;
            }
            else if (imageName.Equals("Brentwood"))
            {
                lat = 51.087189056051685;
                lon = -114.13224220275879;
            }
            else if (imageName.Equals("Dalhousie"))
            {
                lat = 51.1033333116351;
                lon = -114.16082382202148;
            }
            else if (imageName.Equals("Saskatoon"))
            {
                lat = 51.06432411023551;
                lon = -114.03851509094238;
            }
            else if (imageName.Equals("University"))
            {
                lat = 51.06205857130617;
                lon = -114.09524917602539;
            }
            else if (imageName.Equals("Winnipeg"))
            {
                lat = 51.03351407558057;
                lon = -114.03619766235352;
            }

            thePictureMap.ImagePath = imagePath;
            thePictureMap.Latitude = lat;
            thePictureMap.Longitude = lon;
            thePictureMap.ZoomLevel = 0;    // TODO

            return thePictureMap;

        }

        #endregion


    }
}
